import { Pipe, PipeTransform } from '@angular/core';
import { KeyValueOutput } from "../..";

@Pipe({
	name: 'dictionary'
})
export class DictionaryPipe implements PipeTransform {

	transform(value: string, dics: Array<KeyValueOutput>): string {
		if (dics) {
			const finder = dics.filter(e => e.dValue && value && e.dValue.toString() === value.toString());
			return finder.length > 0 ? finder[0].caption : '无';
		}
		return value;
	}

}
